using System.Collections.Generic;

using octalforty.BizFramework.Core;

using octalforty.Waffle.ObjectModel.Business.Collections;

namespace octalforty.Waffle.ObjectModel.Business.Objects
{
    /// <summary>
    /// Represents a single discussion in a <see cref="Forum"/> in octalforty Waffle.
    /// </summary>
    public class Discussion : BusinessObjectWithNameBase, IBusinessObjectWithVersionTag
    {
        #region Private Member Variables
        private long versionTag;
        private Forum forum;
        private IList<DiscussionPost> internalPosts = new List<DiscussionPost>();
        #endregion

        #region Protected Properties
        /// <summary>
        /// Gets or sets a reference to the <see cref="IList{T}"/> which contains
        /// the collection of <see cref="DiscussionPost"/> objects for this <see cref="Discussion"/>.
        /// </summary>
        protected IList<DiscussionPost> InternalPosts
        {
            get { return internalPosts; }
            set { internalPosts = value; }
        }
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets or sets a reference to the <see cref="Forum"/> this <see cref="Discussion"/> belongs to.
        /// </summary>
        public virtual Forum Forum
        {
            get { return forum; }
            set { forum = value; }
        }

        /// <summary>
        /// Gets a reference to the <see cref="DiscussionPostCollection"/> which contains a collection of
        /// all <see cref="DiscussionPost"/> objects for this <see cref="Discussion"/> in chronological order.
        /// </summary>
        public virtual DiscussionPostCollection Posts
        {
            get { return new DiscussionPostCollection(InternalPosts); }
        }
        #endregion

        /// <summary>
        /// Initializes a new instance of <see cref="Discussion"/> class.
        /// </summary>
        public Discussion()
        {
        }

        /// <summary>
        /// Initializes a new instance of <see cref="Discussion"/> class.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="forum"></param>
        public Discussion(long id, string name, Forum forum) : base(id, name)
        {
            this.forum = forum;
        }

        #region IBusinessObjectWithVersionTag Members
        /// <summary>
        /// Gets or sets business object version tag.
        /// </summary>
        public virtual long VersionTag
        {
            get { return versionTag; }
            set { versionTag = value; }
        }
        #endregion
    }
}
